import 'package:flutter/material.dart';
import 'package:client/common/event.dart';
import 'package:client/model/chat_item_model.dart';
import 'package:client/view/chat/chat_list.dart';
import 'package:client/view/chat/chat_talk.dart';

class ChatRoute extends StatefulWidget {
  const ChatRoute({super.key});

  @override
  _ChatRouteState createState() => _ChatRouteState();
}

class _ChatRouteState extends State<ChatRoute>
    with AutomaticKeepAliveClientMixin {
  Widget actionView = Container(
    color: Colors.white,
  );

  chatChange(ChatItemModel m) {
    print(m);
    print("chat talk");
    print(m.name);

    bus.emit(EventBusSet.chatChange, m);

    // setState(() {
    //   actionView = ChatTalk(m);
    // });
  }

  @override
  Widget build(BuildContext context) {
    print("build");
    return Scaffold(
      // appBar: AppBar(
      //   title: Text("on line"),
      // ),
      // body:  ListView(
      //   children: listItem,
      // ),
      body: Row(
        children: [
          Expanded(
              flex: 1,
              child: Container(
                decoration: BoxDecoration(border: Border(right: BorderSide())),
                // color: Colors.yellow,
                height: double.infinity,
                child: ChatList(),
              )),
          Expanded(
              flex: 4,
              child: Container(
                // color: Colors.red,
                height: double.infinity,
                child: const ChatTalk(),
              )),
        ],
      ),
    );
  }

  @override
  bool get wantKeepAlive => true;
}
